package com.jumi.microservice.controller.logistics.admin;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.dto.logistics.*;
import com.jumi.microservice.dto.logistics.admin.WarehouseListResponse;
import com.jumi.microservice.service.logistics.admin.RelocateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author by mazhao
 * @Classname RelocateController
 * @Description TODO
 * @Date 2020/8/20 9:22
 */
@RestController
@RequestMapping("/admin/relocate")
@Api(tags = {"调仓相关接口"})
public class RelocateController extends BaseController {

    @Resource
    RelocateService relocateService;

    @ApiOperation("调仓页面仓库列表")
    @PostMapping("/getRelocateRepoList")
    public ResponseResult<List<RelocateRepoListResponse>> getRelocateRepoList(RelocateRepoListRequest request){
        return success(relocateService.getRelocateWarehouseList(request));
    }

    @ApiOperation("调仓页面SPU列表")
    @PostMapping("/getRelocateGoodsList")
    public TableDataInfo<RelocateGoodsListResponse> getRelocateGoodsList(RelocateGoodsListRequest request){
        return relocateService.getRelocateGoodsList(request);
    }

    @ApiOperation("调仓提交")
    @PostMapping("/relocateSubmit")
    public ResponseResult<Boolean> getRelocateGoodsList(RelocateSubmitRequest request){
        Long uid = getUid();
        String name = getUserName();
        return success(relocateService.relocateSubmit(request,uid,name));
    }

    @ApiOperation("所有仓库列表")
    @PostMapping("/warehouseList")
    public ResponseResult<List<WarehouseListResponse>> warehouseList(){
        return success(relocateService.warehouseList());
    }

    @ApiOperation("所有供应商列表")
    @PostMapping("/supplyList")
    public ResponseResult<List<SupplyListResponse>> supplyList(){
        return success(relocateService.supplyList());
    }

}
